namespace ASPNET.StarterKit.IssueTracker.BusinessLogicLayer
{
    using ASPNET.StarterKit.IssueTracker.DataAccessLayer;
    using System;
    using System.Collections.Generic;

    public class IssueHistory
    {
        private string _CreatorDisplayName;
        private DateTime _DateCreated;
        private int _Id;
        private int _IssueId;

        public IssueHistory(int historyId, int issueId, string creatorDisplayName, DateTime dateCreated)
        {
            if (issueId <= DefaultValues.GetIssueIdMinValue())
            {
                throw new ArgumentOutOfRangeException("IssueId");
            }
            this._Id = historyId;
            this._IssueId = issueId;
            this._CreatorDisplayName = creatorDisplayName;
            this._DateCreated = dateCreated;
        }

        public static IssueHistoryCollection GetIssueHistoryByIssueId(int issueId)
        {
            if (issueId <= DefaultValues.GetIssueIdMinValue())
            {
                throw new ArgumentOutOfRangeException("issueId");
            }
            return DataAccessLayerBaseClassHelper.GetDataAccessLayer().GetIssueHistoryByIssueId(issueId);
        }

        public static IssueHistoryValueCollection GetIssueHistoryValueByHistoryId(int HistoryId)
        {
            if (HistoryId < 0)
            {
                throw new ArgumentOutOfRangeException("issueId");
            }
            return DataAccessLayerBaseClassHelper.GetDataAccessLayer().GetHistoryValueByHistoryId(HistoryId);
        }

        public string CreatorDisplayName
        {
            get
            {
                if ((this._CreatorDisplayName == null) || (this._CreatorDisplayName.Length == 0))
                {
                    return string.Empty;
                }
                return this._CreatorDisplayName;
            }
        }

        public DateTime DateCreated
        {
            get
            {
                return this._DateCreated;
            }
        }

        public int Id
        {
            get
            {
                return this._Id;
            }
        }

        public int IssueId
        {
            get
            {
                return this._IssueId;
            }
            set
            {
                if (value <= DefaultValues.GetIssueIdMinValue())
                {
                    throw new ArgumentOutOfRangeException("value");
                }
                this._IssueId = value;
            }
        }
    }
}

